﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input.Touch;

namespace GauntletFramework.StateManagment.Transition
{
    public class FadeBlackTransitionState : TransitionState
    {
        public FadeBlackTransitionState(float Time)
            : base(Time)
        {
        }

        public override GameOrientation GameOrientation { get { if (Progress < 0.5f) return Start.GameOrientation; else return End.GameOrientation; } }
        
        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);

            SpriteBatch sb = ((GNTMainGame)Game).SpriteBatch;

            if (Progress < 0.5f)
            {
                sb.Draw(StartRenderTexture2D, StaticGame.ScreenSize, Color.White);
                Color fade = new Color(0.0f, 0.0f, 0.0f, Progress / 0.5f);

                sb.Draw(StaticGame.Game.MonoColor, Game.GraphicsDevice.Viewport.Bounds, fade);
            }
            else
            {
                sb.Draw(EndRenderTexture2D, StaticGame.ScreenSize, Color.White);
                Color fade = new Color(0.0f, 0.0f, 0.0f, (1.0f - Progress) / 0.5f);

                sb.Draw(StaticGame.Game.MonoColor, Game.GraphicsDevice.Viewport.Bounds, fade);
            }

        }
    }
}
